package com.trip.wechat.platform.model.message;

import org.springframework.beans.BeanUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * 功能说明: <br>
 * 系统说明: <br>
 * 模块说明: <br>
 * 功能描述: <br>
 */
public class TemplateMessageBuilder {

    private String toUser ;
    private String templateId;
    private String url;
    private String topColor ;
    private final Map<String, TemplateData> data = new HashMap<>();


    public final static TemplateMessageBuilder newBuilder() {
        return new TemplateMessageBuilder();
    }

    public TemplateMessageBuilder setToUser(String toUser) {
        this.toUser = toUser;
        return this;
    }

    public TemplateMessageBuilder setTemplateId(String templateId) {
        this.templateId = templateId;
        return this;
    }

    public TemplateMessageBuilder setUrl(String url) {
        this.url = url;
        return this;
    }

    public TemplateMessageBuilder setTopColor(String topColor) {
        this.topColor = topColor;
        return this;
    }

    public TemplateMessageBuilder addTemplateData(String key, TemplateData templateData) {
        this.data.put(key, templateData);
        return this;
    }

    public TemplateMessageBuilder addTemplateData(String key, String value, String color) {
        TemplateData templateData = new TemplateData();
        templateData.setValue(value);
        templateData.setColor(color);
        return addTemplateData(key, templateData);
    }

    public TemplateMessageBuilder addTemplateData(String key, String value) {
        return addTemplateData(key, value, null);
    }

    public String getToUser() {
        return toUser;
    }

    public String getTemplateId() {
        return templateId;
    }

    public String getUrl() {
        return url;
    }

    public String getTopColor() {
        return topColor;
    }

    public Map<String, TemplateData> getData() {
        return data;
    }

    public TemplateMessageBO build() {
        TemplateMessageBO bo = new TemplateMessageBO();
        BeanUtils.copyProperties(this, bo);
        return bo;
    }
}
